package com.io.example.demoparent.mq.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitMQUtil {


    public static Channel getRabbitChannel() throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory( );
        //工厂ip 链接Rabbit队列
        factory.setHost("192.168.164.131");
        //用户名
        factory.setUsername("guest");
        //密码
        factory.setPassword("guest");
        //创建一个信道
        Connection connection = factory.newConnection( );
        //获取信道
        return connection.createChannel( );
    }
}
